package cn.pugle.encrypt;

/**
 * @author tzp
 * @since 2022/5/19
 */
public class ElfHash {
    public static void main(String[] args) {
        System.out.print(ELFHash(args[0]));
    }

    public static Long ELFHash(String str) {
        long hash = 0;
        long x=0;
        for(int i=0;i<str.length();i++)
        {
            hash = (hash<<4)+str.charAt(i);
            if((x=hash & 0xF0000000L) != 0)
            {
                hash^=(x>>24);
            }
            hash &=~x;
        }
        return hash;
    }
}
